﻿using System;
using System.Reflection;
using Volo.Abp;
using Volo.Abp.Application.Services;

namespace YaAppoint.RoslynCompiler
{
    /// <summary>
    /// 动态编译服务
    /// </summary>
    [RemoteService(isEnabled:false)]
    public interface IDynamicCompilerAppService:IApplicationService
    {
        void AddReferences(Assembly assembly);


        /// <summary>
        ///  动态编译，返回编译后类型
        /// </summary>
        /// <param name="code">C#脚本字符串</param>
        /// <param name="entryMethod">要执行的方法名</param>
        /// <param name="parameters">可变参数</param>
        /// <returns></returns>
        [RemoteService(isEnabled:false)]
        Type CompileAndGetType(string code, string typeName,out  DynamicAssemblyLoadContext assemblyLoadContext);

        /// <summary>
        /// 动态编译，并且创建指定类型的实例(带有依赖注入)
        /// </summary>
        /// <param name="code"></param>
        /// <param name="typeName"></param>
        /// <returns></returns>
        [RemoteService(isEnabled:false)]
        object CreateInstanceWithDI(string code, string typeName,out DynamicAssemblyLoadContext assemblyLoadContext);

        /// <summary>
        /// 运算MD5
        /// </summary>
        string GetCodeMD5(string code);
    }
}
